package ee.graphicscard.controller;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;

public class ViewManager 
{
	private Logger logger = Logger.getLogger(ViewManager.class);
	
	public void navigateTo(String userView, HttpServletRequest request, HttpServletResponse response, ServletContext servletContext)
	{
		try 
		{
			if (userView.equals("main_graphics_card_page"))
			{
				servletContext.getRequestDispatcher("/Graphics_card.jsp").forward(request, response);
			}
			else if (userView.equals("show_graphics_card_exemplar"))
			{
				servletContext.getRequestDispatcher("/Show_or_change_graphics_card_exemplar.jsp").forward(request, response);
			}
			else if (userView.equals("show_no_such_graphics_card_error"))
			{
				servletContext.getRequestDispatcher("/Error.jsp").forward(request, response);
			}
		}
		catch (Exception e) 
		{
			logger.debug(e.getMessage());
		}
	}
}
